package cn.lh.event;

import com.alibaba.fastjson.JSONObject;
import org.springframework.context.ApplicationListener;

import java.util.concurrent.TimeUnit;

/**
 * @描述:
 * @版权: Copyright (c) 2023
 * @作者: linhong
 * @版本: 1.0.0
 * @创建时间: 2023/10/12
 */
//@Configuration
public class MyListener implements ApplicationListener<MyEvent> {


    @Override
    public void onApplicationEvent(MyEvent myEvent) {
        System.out.println("收到基于接口驱动的事件：" + JSONObject.toJSONString(myEvent));
        // 模拟事件处理
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
